package cn.pzaily.fealetter.controller;

import cn.pzaily.crab.tools.http.enumeration.AppHttpCodeEnum;
import cn.pzaily.crab.tools.http.result.ResponseResult;
import cn.pzaily.fealetter.dto.BatchParamsDTO;
import cn.pzaily.fealetter.dto.ParamsDTO;
import cn.pzaily.fealetter.service.SendService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * create by pangzhuang on 2021/12/7
 */
@Api(tags = "邮件发送接口")
@RestController
@RequestMapping(value = "/mail")
public class SendMailController {


    private SendService sendService;

    public SendMailController(SendService sendService) {
        this.sendService = sendService;
    }

    @ApiOperation("发送邮件")
    @RequestMapping(value = "/send", method = RequestMethod.POST)
    public ResponseResult send(@RequestBody ParamsDTO paramsDTO) {
        sendService.send(paramsDTO);
        return ResponseResult.okResult(AppHttpCodeEnum.SEND_MESS_SUCCESS);
    }

    @ApiOperation("批量发送邮件")
    @RequestMapping(value = "/batchSend", method = RequestMethod.POST)
    public ResponseResult batchSend(@RequestBody BatchParamsDTO batchParamsDTO) {

        sendService.batchSend(batchParamsDTO);

        return ResponseResult.okResult(AppHttpCodeEnum.SEND_MESS_SUCCESS);
    }


}
